program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  mass: array of integer;
  n, i, j: integer;

begin
  read (n);
  setlength (mass, n);
  for I := 0 to n - 1 do
    read (mass[i]);
  for I := 0 to n - 2 do
    for j := i+1 to n - 1 do
      if (mass[i]+mass[j]=1000) then
      begin
        write (mass[i], ' ', mass[j]);
        exit;
      end;
  readln;
  readln;
end.
